package com.wjx.quartz;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;

import java.util.Date;

import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;

public class QuartzTest {
    public static void main(String[] args) throws Exception {
        Scheduler sched = StdSchedulerFactory.getDefaultScheduler();

        sched.start();

        JobDetail job = newJob(HelloQuartz.class)
                .withIdentity("myJob3", "group3")
                .usingJobData("name", "quartz")
                .build();

        Trigger trigger = newTrigger()
                .withIdentity("myTrigger3", "group3")
                .startNow()
                .withSchedule(simpleSchedule()
                        .withIntervalInSeconds(3)
                        .withRepeatCount(5)
                )
                .build();

        Date date = sched.scheduleJob(job, trigger);
    }
}
